/**
 * Created by duqunxing on 2017/1/3.
 */
import {Routes, RouterModule} from "@angular/router";
import {LoginComponent} from "./login/login.component";
import {PageNotFoundComponent} from "./common/page-not-found.component";
import {NgModule} from "@angular/core";
import {DispatcherComponent} from "./dispatcher/dispatcher.component";
import {DispatcherResolveService} from "./dispatcher/dispatcher-resolve.service";
import {AuthGuardService} from "./services/auth-guard.service";
import {ClientAuthComponent} from "./auth/client-auth.component";
import {ErrorComponent} from "./common/error.component";
import {ClientAuthResolveService} from "./auth/client-auth-resolve.service";

// Components


const appRoutes: Routes = [
  // Root
  {
    path: 'login',
    component:LoginComponent
  },
  {
    path:'portal',
    canActivate: [AuthGuardService],
    loadChildren:"./portal/portals.module#PortalsModule"
  },
  {
    path:'samples',
    canActivate: [AuthGuardService],
    loadChildren:"./samples/samples.module#SamplesModule"
  },
  {
    path:'client-auth',
    component:ClientAuthComponent,
    resolve:{
      redirctUrl : ClientAuthResolveService
    }
  },
  {
    path: 'error',
    component: ErrorComponent
  },
  {
    path:'',
    component:DispatcherComponent,
    resolve:{
      dispatcher : DispatcherResolveService
    }
  },
  {
    path:'**',
    component:PageNotFoundComponent
  }
];


@NgModule({
  imports: [
    RouterModule.forRoot(appRoutes,{
      enableTracing:true,useHash: true
    })
  ],
  exports: [
    RouterModule
  ]
})
export class AppRoutingModule {}
